<?php


namespace app\controller\equipment;
require_once __DIR__.'/../../common/AuthController.php';
use app\common\AuthController;


/**
 * 终端日志
 */
class Log extends AuthController
{   


    /**
     * 初始化操作
     */
    public function init()
    {

    }
	

    /**
     * 获取终端日志列表
     */
	public function api_equipment_log_getList($msg)
    {   
        global $db;
        $info = [
            'page' =>  isset($msg['data']['page'])?$msg['data']['page']:1,
            'rows' => isset($msg['data']['rows'])?$msg['data']['rows']:15,
            'equipment_name' => isset($msg['data']['equipment_name'])?$msg['data']['equipment_name']:'',
            'id' => isset($msg['data']['id'])?$msg['data']['id']:'',
            'type' => isset($msg['data']['type'])?$msg['data']['type']:'',
            'merchant_name' => isset($msg['data']['merchant_name'])?$msg['data']['merchant_name']:'',
            'region_name' => isset($msg['data']['region_name'])?$msg['data']['region_name']:'',
        ];
        $limit = ($info['page']-1)*$info['rows'].','.$info['rows'];
        $where = "is_delete = 0";
        if(!empty($info['id'])){
            $where .= " AND id =".$info['id'];
        }
        if(!empty($info['type'])){
            $where .= " AND type =".$info['type'];
        }
        if(!empty($info['equipment_name'])){
            $where .= " AND equipment_name LIKE '%".$info['equipment_name']."%'";
        }
        if(!empty($info['merchant_name'])){
            $where .= " AND merchant_name LIKE '%".$info['merchant_name']."%'";
        }
        if(!empty($info['region_name'])){
            $where .= " AND region_name LIKE '%".$info['region_name']."%'";
        }
		$list = $db->query("select * from equipment_log where ".$where ." order by id  desc limit ".$limit); 
        $count =  $db->query("SELECT count(*) as count from equipment_log WHERE ".$where);
        return $this->outMessage(10000,'获取成功',$list,'success',$count[0]['count']);
	}



 

}
